]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
ci: Fix meson-install usage check
authorFlorian Müllner <fmuellner@gnome.org>
Mon, 20 Mar 2023 00:47:30 +0000 (01:47 +0100)
committerMarge Bot <marge-bot@gnome.org>
Thu, 20 Apr 2023 15:59:56 +0000 (15:59 +0000)
The script has four mandatory arguments, and also accepts optional
build options that are passed on to meson. Checking for the number
of arguments *before* filtering out the optional ones means that

`./install-meson-project.sh -Done=1 -Dtwo=2 -Dthree=3 -Dfour=4`

is considered valid, even though not a single required argument
is passed.

Fix this by filtering out the arguments before doing the usage
check. As it is a nice touch to have usage information at the
top of the script, move the message into a usage() function at
the top.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2712>

.gitlab-ci/install-meson-project.sh

index f2bacca9b51eeb33d557626909f8a5ded976f68f..df188673ce89bbba07f6e55f592c78298383669f 100755 (executable)
@@ -2,12 +2,17 @@
 
 set -e
 
-if [[ $# -lt 4 ]]; then
-  echo Usage: $0 [options] [repo-url] [commit] [subdir]
-  echo  Options:
-  echo    -Dkey=val
-  exit 1
-fi
+usage() {
+  cat <<-EOF
+       Usage: $(basename $0) [OPTION…] REPO_URL COMMIT SUBDIR PREPARE
+
+       Check out and install a meson project
+
+       Options:
+         -Dkey=val      Option to pass on to meson
+
+       EOF
+}
 
 MESON_OPTIONS=()
 
@@ -16,6 +21,11 @@ while [[ $1 =~ ^-D ]]; do
   shift
 done
 
+if [[ $# -lt 4 ]]; then
+  usage
+  exit 1
+fi
+
 REPO_URL="$1"
 COMMIT="$2"
 SUBDIR="$3"